#include "headfiles.h"
#include <gtest/gtest.h>

using namespace std;

#define STACK_SIZE 30

class SetOfStackTest : public ::testing::Test {
protected:
	virtual void SetUp() {
	}

	virtual void TearDown() {
	}

	SetOfStack<int> stack_;
};

TEST_F(SetOfStackTest, StackEmpty) {
	EXPECT_EQ(true, stack_.empty());
	stack_.push(1);
	EXPECT_EQ(false, stack_.empty());
	stack_.pop();
	EXPECT_EQ(true, stack_.empty());
}

TEST_F(SetOfStackTest, PushPopTop) {
	stack_.push(1);
	stack_.push(2);
	EXPECT_EQ(2, stack_.top());
	EXPECT_EQ(true, stack_.pop());
	EXPECT_EQ(1, stack_.top());
	EXPECT_EQ(true, stack_.pop());
	int i;
	for (i = 0; i < STACK_SIZE + 2; i++) {
		EXPECT_EQ(true, stack_.push(i));
	}

	EXPECT_EQ(31, stack_.top());
	EXPECT_EQ(true, stack_.pop());
	EXPECT_EQ(30, stack_.top());
}	

TEST_F(SetOfStackTest, size) {
	EXPECT_EQ(0, stack_.size());
	ASSERT_EQ(true, stack_.push(1));
	EXPECT_EQ(1, stack_.size());
	ASSERT_EQ(true, stack_.push(1));
	EXPECT_EQ(2, stack_.size());

	int i;
	for (i = 0; i < STACK_SIZE; i++) {
		EXPECT_EQ(true, stack_.push(i));
	}

	EXPECT_EQ(32, stack_.size());
};

TEST_F(SetOfStackTest, SubStackNum) {
	EXPECT_EQ(true, stack_.push(1));
	EXPECT_EQ(1, stack_.getSubStackNum());
	stack_.pop();

	int i;
	for (i = 0; i < STACK_SIZE; i++) {
		EXPECT_EQ(true, stack_.push(i));
	}
	EXPECT_EQ(1, stack_.getSubStackNum());
	stack_.push(10);

	EXPECT_EQ(31, stack_.size());
	EXPECT_EQ(2, stack_.getSubStackNum());
	stack_.pop();
	EXPECT_EQ(1, stack_.getSubStackNum());
};
